/*
选择角色
*/

layui.define(['form','cosjs','scene'], function (exports) {
    let $ = layui.jquery,form = layui.form,scene = layui.scene;

    function create() {

    }

    create.finish = function(){
        $('#game-select-show').on('click', function () {
            scene.show('game/select');
            return false;
        })

        form.on('submit(game-create-submit)', function () {
            let data = arguments[0].field;
            if(!data['name']){
                return scene.error('角色名称不能为空');
            }
            scene.gamesdk.game.create(data).then((role) => {
                scene.show("game/select");
            }).catch(err => {
                return scene.error(err);
            })
            return false;
        })
    }

    exports('game/create', create);
})